package cn.itsource.basic.config.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 声明这个springmvc的配置类
 */
@Configuration
public class PetHomeWebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    /**
     * 管理拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //注册拦截器  exclude:排除
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") //拦截所有
                .excludePathPatterns("/login/**","/file/**","/shop/settlement")
                .excludePathPatterns("/pay/**","/user/**","/wechat/**")  //放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");

    }
}
